#ifndef TC_EX_HH
#define TC_EX_HH

/** \file Ex.hh 
 * Declarations for the various exception classes.
 *
 * (C) Copyright  Semih Cemiloglu
 * All rights reserved, see COPYRIGHT file for details.
 *
 * $Id: Ex.hh 117 2006-06-19 06:49:41Z semihc $
 *
 *
 */

#include <exception>
#include <iosfwd>
#include "Global.hh"

namespace TC {


/**
 * A 'Base' exception class that only contains
 * description string ans reason code.
 */
struct Ex : public std::exception
{
  // CREATORS
  Ex(const char* desc = 0, int reason = 0) :
      m_desc(desc), m_reason(reason) {}
  virtual ~Ex() throw() {}

  // ACCESSORS
  //! Print this exception into the log stream
  virtual void print(std::ostream&) const;
  //! Returns generic description of the exception
  virtual const char* what() const throw()
  { return m_desc; }
  
  // MEMBERS
  const char* m_desc;
  const int m_reason;
};

  
/**
 * A 'Simple' exception class which contains
 * file name and line number usually
 * obtained from __FILE__ and __LINE__ macros.
 */
struct ExSimple : public Ex
{
  // CREATORS
  ExSimple(const char* desc = 0, int reason = 0, 
           const char* file = 0, int lineno = 0, const char* func = 0) :
      Ex(desc, reason), m_file(file), m_lineno(lineno), m_func(func) {}
  virtual ~ExSimple() throw() {}
  
  // ACCESSORS
  virtual void print(std::ostream&) const;

  // MEMBERS
  const char* m_file;
  const int m_lineno;
  const char* m_func;
};


//! Unknown Exception message
extern const char* const UnknownExStr;


} // end namespace




#endif /* Include guard */
